package com.ruoyi.project.oms.paeaAuAuditGroupUserRel.controller;

import java.util.List;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ruoyi.project.oms.paeaAuAuditGroupUserRel.domain.PaeaAuAuditGroupUserRel;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.oms.paeaAuAuditGroupUserRel.service.IPaeaAuAuditGroupUserRelService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import java.util.Arrays;

import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 监督小组人员Controller
 *
 * @author gang.wei
 * @date 2020-03-23
 */
@Controller
@RequestMapping("/oms/paeaAuAuditGroupUserRel")
public class PaeaAuAuditGroupUserRelController extends BaseController
{
    private String prefix = "oms/paeaAuAuditGroupUserRel";

    @Autowired
    private IPaeaAuAuditGroupUserRelService paeaAuAuditGroupUserRelService;

    @RequiresPermissions("oms:paeaAuAuditGroupUserRel:view")
    @GetMapping()
    public String paeaAuAuditGroupUserRel()
    {
        return prefix + "/paeaAuAuditGroupUserRel";
    }

    /**
     * 查询监督小组人员列表
     */
    @RequiresPermissions("oms:paeaAuAuditGroupUserRel:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(PaeaAuAuditGroupUserRel paeaAuAuditGroupUserRel)
    {
        startPage();
        List<PaeaAuAuditGroupUserRel> list = paeaAuAuditGroupUserRelService.list(new QueryWrapper<>(paeaAuAuditGroupUserRel));
        return getDataTable(list);
    }

    /**
     * 导出监督小组人员列表
     */
    @RequiresPermissions("oms:paeaAuAuditGroupUserRel:export")
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(PaeaAuAuditGroupUserRel paeaAuAuditGroupUserRel)
    {
        List<PaeaAuAuditGroupUserRel> list = paeaAuAuditGroupUserRelService.list(new QueryWrapper<>(paeaAuAuditGroupUserRel));
        ExcelUtil<PaeaAuAuditGroupUserRel> util = new ExcelUtil<PaeaAuAuditGroupUserRel>(PaeaAuAuditGroupUserRel.class);
        return util.exportExcel(list, "paeaAuAuditGroupUserRel");
    }

    /**
     * 新增监督小组人员
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存监督小组人员
     */
    @RequiresPermissions("oms:paeaAuAuditGroupUserRel:add")
    @Log(title = "监督小组人员", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(PaeaAuAuditGroupUserRel paeaAuAuditGroupUserRel)
    {
        return toAjax(paeaAuAuditGroupUserRelService.saveOrUpdate(paeaAuAuditGroupUserRel));
    }

    /**
     * 修改监督小组人员
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") String id, ModelMap mmap)
    {
        PaeaAuAuditGroupUserRel paeaAuAuditGroupUserRel = paeaAuAuditGroupUserRelService.getById(id);
        mmap.put("paeaAuAuditGroupUserRel", paeaAuAuditGroupUserRel);
        return prefix + "/edit";
    }

    /**
     * 修改保存监督小组人员
     */
    @RequiresPermissions("oms:paeaAuAuditGroupUserRel:edit")
    @Log(title = "监督小组人员", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(PaeaAuAuditGroupUserRel paeaAuAuditGroupUserRel)
    {
        return toAjax(paeaAuAuditGroupUserRelService.saveOrUpdate(paeaAuAuditGroupUserRel));
    }

    /**
     * 删除监督小组人员
     */
    @RequiresPermissions("oms:paeaAuAuditGroupUserRel:remove")
    @Log(title = "监督小组人员", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(paeaAuAuditGroupUserRelService.removeByIds(Arrays.asList(ids.split(","))));
    }
}
